<?php

namespace app\api\controller;

use app\api\service\NoticeService;
use app\api\validate\NoticeValidate;

class Notice extends Base
{
    protected $middleware = ['NotFoundMiddleware'];

    /**
     * 获取消息列表
     * @needLogin TRUE
     * @method GET
     * @return void
     */
    public function getNoticeList()
    {
        if (($msg = NoticeValidate::getNoticeList($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = NoticeService::getNoticeList($this->_user_info, $this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 用户读取消息
     * @needLogin TRUE
     * @method POST
     * @return void
     */
    public function userReadNotice()
    {
        if (($msg = NoticeValidate::userReadNotice($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = NoticeService::userReadNotice($this->_user_info, $this->params);
        apiReturn($code, $msg, $data);
    }
}